<template>
	<label>{{label}}</label>
</template>

<script>
	export default {
		name: "TableLabelRenderer",
		props: ["componentModel", "tableData"],
		data() {
			return {
				label: ""
			}
		},
		mounted() {
			var selectItemMap = this.tableData["_selectItemMap"];
			var selectItemList = selectItemMap[this.componentModel.id];
			var value = this.tableData[this.componentModel.dataField];
			if (value != null) {
				if (typeof value == "string" && selectItemList!=null) {
					var valueArray = value.split(",");
					if (valueArray.length > 1) {
						var label = "";
						for (var i = 0; i < valueArray.length; i++) {
							if (i > 0) {
								label += ",";
							}
							for (var j = 0; j < selectItemList.length; j++) {
								if (selectItemList[j].value == valueArray[i]) {
									label += selectItemList[j].name;
									break;
								}
							}
						}
						this.label = label;
						return;
					}
				}
				if (selectItemList != undefined) {
					for (i = 0; i < selectItemList.length; i++) {
						if (selectItemList[i].value == value) {
							this.label = selectItemList[i].name;
							break;
						}
					}
				} else {
					this.label = value;
				}
			}

		},
		methods: {
			setProp() {

			}
		},
	}
</script>

<style>
</style>
